package br.com.fatec.cqr.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

public class Tela extends JFrame {
	JPanel painelPrincipal = new JPanel();

	public Tela(String titulo) {
		Color backgroundColor = new Color(119, 136, 153);

		Toolkit size = Toolkit.getDefaultToolkit();

		int height = size.getScreenSize().height;
		int width = size.getScreenSize().width;

		URL url = this.getClass().getResource(
				"/br/com/fatec/cqr/view/resources/logo_aplicacao.png");
		Image icon = Toolkit.getDefaultToolkit().getImage(url);
		this.setIconImage(icon);

		this.getContentPane().setBackground(backgroundColor);
		this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);

		this.setSize(width, height -= height * 0.05);

		this.setTitle(titulo);

		initPainel();
		initPainelInferior();
		initPainelOpcoes();
		initPainelSqleNoSql();
		this.add(painelPrincipal);
		this.setVisible(true);

	}

	public void initPainel() {
		painelPrincipal.setBackground(new Color(119, 136, 153));
		BorderLayout borderLayout = new BorderLayout();
		painelPrincipal.setLayout(borderLayout);
	}

	public void initPainelInferior() {

		ToolBarInferior menuInferior = new ToolBarInferior();
		painelPrincipal.add(menuInferior, BorderLayout.NORTH);

	}

	public void initPainelOpcoes() {

		MenuOpcoes menuOpcoes = new MenuOpcoes();
		this.setJMenuBar(menuOpcoes);
	}

	public void initPainelSqleNoSql() {
		PainelNoSql painelNoSql = new PainelNoSql();
		PainelSql painelSql = new PainelSql();

		GridLayout layoutTexto = new GridLayout(2, 1);
		JPanel painelBanco = new JPanel();

		painelBanco.setLayout(layoutTexto);
		painelBanco.add(painelSql.textPanel);
		painelBanco.add(painelNoSql.result);

		painelPrincipal.add(painelBanco, BorderLayout.CENTER);
	}

}
